import api from '../../../fetch/api'

export default {
  data() {
    return {
      parkNameListRow: {
        searchParams: {},
        pageNumber: 1,
        total: 0,
        theadsInfo: [
          {
            index: 0,
            isShow: false,
            prop: 'reno',
            text: '序号',
            width: 68
          },
          {
            index: 1,
            isShow: false,
            prop: 'm',
            text: '停车场',
            minWidth: 110
          }
        ],
        tbodysInfo: []
      },
      parkNameRow: {},
      accountList: '',
      accountVo: {
        theadsInfo: [{
            index: 0,
            isShow: false,
            prop: 'thirdTransactionSysStr',
            text: '到停车场账户',
            minWidth: 120
          },
          {
            index: 1,
            isShow: false,
            prop: 'payAccount',
            text: '商户号',
            minWidth: 120
          },
          {
            index: 2,
            isShow: false,
            prop: 'totalValue',
            text: '金额',
            minWidth: 120
          },
        ]
      },
    }
  },
  created() {
    
  },
  methods: {
    // 重新生成按钮
    reBuild(){
      this.$refs.myReBuildBtn.reBuild()
    },
    handleSizeChange(val) {
      var self = this;
      self.tmpdetailModalData.pageSize = Number(val);
      self.tmpdetail_list();
    },
    handleCurrentChange(val) {
      var self = this;
      self.tmpdetailModalData.pageNumber = Number(val);
      self.tmpdetail_list();
    },
    getList() {
      if (!this.searchParams.query_chargeDateStart) {
        this.showToast('请选择时间区间');
        return false;
      }
      let params = $.extend({}, this.searchParams, this.otherParams);
      this.getItemList(params);
    },
    getItemList(aparams) { //查询列表
      let self = this,
        params = {
          page: this.pageNumber,
          rp: this.pageSize
        };
      params = $.extend({}, params, aparams);
      api.fetchGet('/report/tmp_charge/pageList.do', params)
        .then(res => {
          let data = res.data,
            list = data.rows;
          self.tbodysInfo = [];
          for(let i = 0; i<list.length; i++){
            let obj = list[i]
            obj.onlineBillTimes = '(' + obj.onlineBillTimes + ')'
            obj.offlineBillTimes = '(' + obj.offlineBillTimes + ')'
            obj.allPayOriginTimes = '(' + obj.allPayOriginTimes + ')'
            obj.unknownPayOriginTimes = '(' + obj.unknownPayOriginTimes + ')'
            obj.gatePayOriginTimes = '(' + obj.gatePayOriginTimes + ')'
            obj.centerPayOriginTimes = '(' + obj.centerPayOriginTimes + ')'
            obj.selfPayOriginTimes = '(' + obj.selfPayOriginTimes + ')'
            obj.onlinePayOriginTimes = '(' + obj.onlinePayOriginTimes + ')'
            obj.scoreRelief = '(' + obj.scoreRelief + ')'
            obj.allCouponTimes = '(' + obj.allCouponTimes + ')'
            obj.unknownCouponTimes = '(' + obj.unknownCouponTimes + ')'
            obj.autoCouponTimes = '(' + obj.autoCouponTimes + ')'
            obj.localCouponTimes = '(' + obj.localCouponTimes + ')'
            obj.traderCouponTimes = '(' + obj.traderCouponTimes + ')'
            obj.onlineParkCouponTimes = '(' + obj.onlineParkCouponTimes + ')'
            obj.onlineCouponTimes = '(' + obj.onlineCouponTimes + ')'
            self.tbodysInfo.push(obj)
          }
          self.total = data.total;
        }, err => {})
    },
    exportData() {
      let self = this;
      let theadsArr = []
      for(let i = 0; i<self.theadsInfo.length; i++){
        if(self.theadsInfo[i].checked){
          theadsArr.push(self.theadsInfo[i].prop)
        }
      }
      let params = {
        meterList: theadsArr.join(',')
      };
      params = $.extend({}, params, this.searchParams, this.otherParams);
      self.showDialog("确认导出该报表?", '', function () {
        self.toExportAsync('report/tmp_charge/export.do', params)
      })
    },
    toOpenParkList(row, modalName) { //打开详情
      this.parkNameRow = row;
      this.toOpenModal(modalName);
      this.getParkNameList(row);
    },
    payParkValueModal_open(index) {
      let self = this;
      self.payParkValueModalData.tbodysInfo = [];
      self.payParkValueModalData.tbodysInfo.push(self.tbodysInfo[index].financeDetail);
      this.toOpenModal('payParkValueModal');
    },
    tmpdetail_open(data) {
      //按钮详情弹框
      this.tmpdetailModalData.list_data = data;
      this.tmpdetailModalData.total = data.allBillTimes;
      this.tmpdetailModalData.pageNumber = 1;
      this.tmpdetailModalData.pageSize = 10;
      this.tmpdetail_list();
      this.toOpenModal('tmpdetailModal');
    },
    tmpdetail_list() {
      let self = this,
        params = {
          query_parkId: self.tmpdetailModalData.list_data.parkId,
          timeDim: self.searchParams.timeDim,
          query_date: self.tmpdetailModalData.list_data.statDate,
          page: self.tmpdetailModalData.pageNumber,
          rp: self.tmpdetailModalData.pageSize
        };
      params = $.extend({}, params);
      api.fetchGet('/report/tmp_charge/detailPageList.do', params)
        .then(res => {
          let data = res.data,
            list = data.rows;
          self.tmpdetailModalData.parentLength = list.length;
          self.tmpdetailModalData.tbodysInfo = list;
          self.tmpdetailModalData.pageNumber = data.page;
        }, err => {})
    },

    filterMultiCheck(selectionArr) { //必须定义获取多列的方法
      let result = [];
      selectionArr.map((item) => {
        result.push(item.id);
      });
      return result;
    },
    getReportDetailPagination(curPage, pageSize) {
      this.tmpdetailModalData.pageNumber = curPage;
      this.tmpdetailModalData.pageSize = pageSize ? pageSize : this.tmpdetailModalData.pageSize;
      this.tmpdetail_list();
    },
    accountShowModal(row) {
      let self = this,
        params = {
          ids: row.ids,
        };
      params = $.extend({}, params);
      api.fetchPost('/report/tmp_charge/getAccountDetail.do', params)
        .then(res => {
          let data = res.data,
            list = data.rows;
          self.accountList = list;
          this.toOpenModal('accountModal', 1);
        }, err => {});
    },
  }
}
